package com.voxel.sense.infomsg.view;

import android.content.Context;
import android.util.AttributeSet;

import com.example.com.common.utils.L;
import com.youth.banner.Banner;

import java.util.List;

/**
 * Created by ChenYiYao on 2018/7/30.
 */
public class CustomBanner extends Banner {

    private int mSize;
    private boolean mflag = false;
    private int mCurrentPosition = -1;

    public CustomBanner(Context context) {
        super(context);
    }

    public CustomBanner(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomBanner(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public Banner setImages(List<?> imageUrls) {
        if (imageUrls != null) {
            mSize = imageUrls.size();
        }
        return super.setImages(imageUrls);
    }

    @Override
    public void onPageScrollStateChanged(int state) {
        if (mCurrentPosition == 0||mCurrentPosition==(mSize+1)) {
//            mc==
        }
        super.onPageScrollStateChanged(state);
//        Log.i(tag,"currentItem: "+currentItem);
//        switch (state) {
//            case 0://No operation
//                if (currentItem == 0) {
//                    viewPager.setCurrentItem(count, false);
//                } else if (currentItem == count + 1) {
//                    viewPager.setCurrentItem(1, false);
//                }
//                break;
//            case 1://start Sliding
//                if (currentItem == count + 1) {
//                    viewPager.setCurrentItem(1, false);
//                } else if (currentItem == 0) {
//                    viewPager.setCurrentItem(count, false);
//                }
//                break;
//            case 2://end Sliding
//                break;
//        }


    }

    @Override
    public void onPageSelected(int position) {
        L.d("-------position" + position);
        mCurrentPosition= position;
//        if ((position == 1 ) || position > mSize) {
//            return;
//        }
//        mflag = true;
        super.onPageSelected(position);
    }
}
